<template>
	<view class="container">
		<!-- 图片轮播图 -->
		<view>
			<swiper class="swiper" :indicator-dots="false" :autoplay="true" :interval="5000" :duration="1000">
				<swiper-item v-for="(item, index) in detailInfo.images" :key="index">
					<image class="swiper-image" :src="item" mode="aspectFill" @click="previewImage"></image>
				</swiper-item>
			</swiper>
		</view>
		<!-- 房屋信息 -->
		<view class="rent-info">
			<view class="rent-info-title">
				<view class="price">{{detailInfo.price}} <text>元/月</text> </view>
				<view class="name">{{detailInfo.title}} <text>{{detailInfo.house_type_text}}</text> </view>
			</view>
			<view class="rent-info-other">
				<view class="rent-info-other-item">
					<view class="direction-name" v-if="detailInfo.orientation == 1">东</view>
					<view class="direction-name" v-if="detailInfo.orientation == 2">南</view>
					<view class="direction-name" v-if="detailInfo.orientation == 3">西</view>
					<view class="direction-name" v-if="detailInfo.orientation == 4">北</view>
					<view class="direction rent-info-other-co">朝向</view>
				</view>
				<view class="rent-info-other-item">
					<view class="area-num">{{detailInfo.proportion}}㎡</view>
					<view class="area rent-info-other-co">面积</view>
				</view>
				<view class="rent-info-other-item">
					<view class="floor-num">{{detailInfo.floor}}楼</view>
					<view class="floor rent-info-other-co">楼层</view>
				</view>
				<view class="rent-info-other-item">
					<view class="type-name" v-if="detailInfo.house_type == 1">自建房</view>
					<view class="type-name" v-if="detailInfo.house_type == 2">小区房</view>
					<view class="type-name" v-if="detailInfo.house_type == 3">别墅</view>
					<view class="type rent-info-other-co">类型</view>
				</view>
			</view>
		</view>
		<!-- 租房标签 -->
		<view class="rent-info-tags">
			<view class="tags-item">{{detailInfo.house_type_text}}</view>
			<view class="tags-item" v-if="detailInfo.floor_type == 1">低楼层</view>
			<view class="tags-item" v-if="detailInfo.floor_type == 2">中楼层</view>
			<view class="tags-item" v-if="detailInfo.floor_type == 3">高楼层</view>
			<view class="tags-item">
				{{detailInfo.pay_type}}
			</view>
			<view class="tags-item">
				{{detailInfo.proportion}}㎡
			</view>
		</view>
		<!-- 房屋介绍 -->
		<view class="rent-introduce">
			<view class="title">房屋介绍</view>
			<view style="padding: 20rpx 0;">
				{{detailInfo.intro}}
			</view>
		</view>
		<view class="rent-address">
			<view class="title">房屋位置</view>
			<view class="name">{{detailInfo.address}}</view>
			<map style="width: 750rpx; height: 500rpx;" enable-scroll="false" :markers="markers"
				:latitude="detailInfo.latitude" :longitude="detailInfo.longitude"></map>
		</view>

		<!-- 底部操作 -->
		<view class="footer">
			<view class="content">
				<view class="opreation">
					<view class="opreation-item">
						<image src="../../../../static/icon/act-city.png" mode=""></image>
						<view>收藏</view>
					</view>
					<view class="opreation-item">
						<image src="../../../../static/icon/act-city.png" mode=""></image>
						<view>分享</view>
					</view>
				</view>
				<view class="contact">电话咨询</view>
			</view>
		</view>
	</view>
</template>

<script>
	import HOME from '@/api/home/index.js'

	export default {
		data() {
			return {
				detailInfo: {},
				markers: []
			}
		},
		onLoad(opt) {
			uni.showLoading({
				title: '获取数据中',
				mask: true
			})
			HOME.getRentDetail(opt.id).then(res => {
				setTimeout(function() {
					uni.hideLoading();
				}, 1000);
				this.detailInfo = res.data;
				this.markers = [{
					iconPath: "../../../../static/icon/wx.png",
					latitude: this.detailInfo.latitude,
					longitude: this.detailInfo.longitude,
					width: 30,
					height: 30,
					anchor: {
						x: .5,
						y: 1
					},
					alpha: 1
				}];
			})
		},
		methods: {
			previewImage() {
				uni.previewImage({
					urls: this.detailInfo.images,
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		position: relative;
		padding-bottom: 100rpx;
	}

	.swiper {
		position: relative;
		max-width: 750rpx;
		height: 450rpx;
		overflow: hidden;

		.swiper-image {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			width: 100%;
			height: 100%;
		}
	}

	.rent-info {
		margin: 30rpx;
		border-bottom: 1rpx solid #ccc;

		.rent-info-title {
			padding: 10rpx;
			display: flex;
			flex-direction: column;

			.price {
				font-size: 60rpx;
				color: red;

				text {
					font-size: 30rpx;
					color: red;
				}
			}

			.name {
				margin-top: 10rpx;
				font-size: 42rpx;
				font-weight: 600;

				text {
					margin-left: 10rpx;
				}
			}
		}

		.rent-info-other {
			display: flex;
			justify-content: space-around;
			padding: 50rpx 0;

			.rent-info-other-item {
				display: flex;
				flex-direction: column;
				align-items: center;
				font-size: 38rpx;

				.rent-info-other-co {
					margin-top: 10rpx;
					font-size: 34rpx;
					color: #999;
				}
			}
		}
	}

	.rent-info-tags {
		display: flex;
		flex-wrap: wrap;
		margin: 30rpx;

		.tags-item {
			margin-right: 30rpx;
			padding: 20rpx;
			border-radius: 10rpx;
			background-color: #999;
			color: #FFFFFF;
			font-size: 30rpx;
		}
	}

	.rent-introduce {
		margin: 40rpx 30rpx;
		border-bottom: 1rpx solid #ccc;

		.title {
			font-size: 46rpx;
			font-weight: 800;
		}
	}

	.rent-address {
		margin-bottom: 60rpx;

		.title {
			margin: 0 30rpx;
			font-size: 46rpx;
			font-weight: 800;
		}

		.name {
			padding: 30rpx;
		}
	}

	.footer {
		position: fixed;
		bottom: 0;
		width: 750rpx;
		background-color: #FFFFFF;
		border-top: 1rpx #ccc solid;

		.content {
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 140rpx;
			padding: 0 30rpx;

			.opreation {
				display: flex;
				justify-content: space-between;
				width: 200rpx;


				.opreation-item {
					display: flex;
					flex-direction: column;
					align-items: center;
					font-size: 36rpx;

					image {
						width: 50rpx;
						height: 50rpx;
					}
				}
			}

			.contact {
				padding: 30rpx 100rpx;
				border-radius: 20rpx;
				background-color: #2A9F93;
				font-size: 36rpx;
				color: #fff;
			}
		}

	}
</style>
